home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 34.zip / BS1 part 34 / FredFish PD 306.adf / Tree / README < prev    next >
Text File  |  1990-01-11  |  4KB  |  89 lines

  1. Tree.  A very, very simple directory tree traversal program.  I wrote it for
  2. two reasons:
  3.  
  4.     - To be able to zoo directory trees
  5.     - To be able to zoo large directories without waiting forever
  6.     - To be able to find the large files on my disk
  7.     - To be able to selectively `backup' files (with zoo, copy or whatnot),
  8.         deleting a certain set of directories and file extensions.
  9.  
  10. So that's what I wanted it to do.  Now how it works.
  11.  
  12. First, it always lists the tree starting at the current directory, and not
  13. prefixed by anything.  Thus, if I'm in the TeX:foo directory, and there is
  14. one file in it called `bar', the program will list the single output line
  15.  
  16. bar
  17.  
  18. and that's it.  All files listed are listed by the pathname starting at the
  19. current directory, so if TeX:foo contained a directory bar with files baz1
  20. and baz2, and TeX:foo also contained fubar, then the output would be
  21.  
  22. bar/baz1
  23. bar/baz2
  24. fubar
  25.  
  26. The files are listed in the order they are encountered, not alphabetically.
  27.  
  28. Simple enough?  Okay, here are the options.  Each option is either an option
  29. keyword or a parameter.  At any given time, one option keyword is in effect,
  30. and all parameters are added.
  31.  
  32. The option keywords are:
  33.  
  34. -d:   Add to the list of directories to be ignored.  Any parameters following
  35.       this will be skipped in the treewalk.  All parameters to this (and other)
  36.       options are case sensitive (this is a bug since the Amiga file system
  37.       isn't case sensitive; fix it if you like.)
  38.  
  39. -x:   Add to the list of file extensions to be ignored.  A file extension is an
  40.       outdated concept, in which the last part of a file name, after the last
  41.       period, is considered an extension.  Thus, the extension of a.b.c is `c';
  42.       the file foo does not have an extension.
  43.  
  44. -f:   Use this (one) parameter as the output format.  The output format is just
  45.       a string, where all `%s' sequences are replaced by the file name, all
  46.       `%d' sequences are replaced by the file size, all %% sequences are
  47.       replaced with a single percent sign, and all other characters are taken
  48.       verbatim.  Useful if you want to build a command file that does something
  49.       to all of the files.
  50.  
  51. -h:   Print a short informational message.
  52.  
  53. Thus, to find the largest files on the disk, I simply use
  54.  
  55.    tree -f "%d %s" | sort
  56.  
  57. (The sort program is also supplied as a freebie; this one reads from stdin and
  58. writes to stdout, or will function as the AmigaDOS one, but it's faster than
  59. the AmigaDOS one, even though it's written in quick and dirty C.)
  60.  
  61. To make a full backup of my disk onto the Syquest, I simply
  62.  
  63.    cd dh0:
  64.    tree -d tex/pk arc autodocs f18 -x dvi log o | zoo aI dh20:backup.date
  65.  
  66. which doesn't backup the directories tex/pk, arc, autodocs, and f18 (since they
  67. are rather large and easily recreated from distribution floppies) and doesn't
  68. save any .dvi, .log, or .o files (since object files especially take up a fair
  69. proportion of the disk), and backups the entire mass with zoo onto another
  70. drive.
  71.  
  72. This procedure (with maybe a few more directories added) can backup my entire
  73. 90MB disk onto a single 25MB file, which I put on a Syquest.  It does take a
  74. while to run (perhaps an hour; never really timed it) but I let it work
  75. overnight.
  76.  
  77. I have restored from these, so it does work.
  78.  
  79. There is so many more things that can be done with `tree', but I haven't decided
  80. on a nice general way to express these things (ie, it should function as a `du'
  81. as well, and an option to `Execute()' rather than print each output line might
  82. be nice) but I'll add them as I need them.  (Hey, the Execute() option is just
  83. a couple of lines of code . . . if you want it, you've got source . . .)
  84.  
  85. Now, whenever I zoo, I just `tree | zoo aI' rather than `zoo'; it's so much
  86. faster!
  87.  
  88. Enjoy!
  89.